<?php
 header("Content-Type:text/html;charset=utf-8");
 session_start();
//  echo session_id();
 //首先判断Cookie是否有记住用户信息
 if (isset($_COOKIE['username'])) {
     $_SESSION['username']=$_COOKIE['username'];
     $_SESSION['islogin']=1;
 }
 $flag=file_exists("pad/sid.txt");
 if ($flag==1) {
     $myfile = fopen("pad/sid.txt", "r") or die("Unable to open file!");
     $txt1=fgets($myfile);
     // echo $txt1;
     fclose($myfile);
 }
 if (isset($_SESSION['islogin']) || $txt1==session_id()) {
     //已经登录
     $myfile = fopen("pad/user.txt", "r") or die("Unable to open file!");
     $txt1=fgets($myfile);
     // echo $txt1;
     fclose($myfile);
     if (isset($txt1)) {
         echo $txt1.":你好，欢迎进入个人中心！<br/>";
     } else {
         echo $_SESSION['username'].":你好，欢迎进入个人中心！<br/>";
     }
     
     echo "<a href='logout.php'>注销</a>";
 } else { //为登录
     echo "你还未登录，请<a href='login.php'>登录</a>";
 }
?> 